from pydantic_settings import BaseSettings
import os


class Settings(BaseSettings):
    DATABASE_HOST: str = "127.0.0.1"
    DATABASE_USER: str = "your_db_user"
    DATABASE_PASSWORD: str = "your_db_password"
    DATABASE_NAME: str = "harborspace_db"

    SECRET_KEY: str = "your_secret_key"
    ACCESS_TOKEN_EXPIRE_MINUTES: int = 60

    DEBUG: bool = False

    @property
    def DATABASE_URL(self) -> str:
        return (
            f"mysql+aiomysql://{self.DATABASE_USER}:{self.DATABASE_PASSWORD}"
            f"@{self.DATABASE_HOST}:3306/{self.DATABASE_NAME}"
        )

    class Config:
        # 指定 .env 文件路径
        env_file = os.path.join(
            os.path.dirname(
                os.path.dirname(os.path.dirname(__file__))
            ),
            ".env"
        ),
        env_file_encoding = "utf-8"


settings = Settings()
